package com.controller;


import com.dto.JsonResult;
import com.service.PhoneService;
import com.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.RolesAllowed;

/**
 * @author Yadasu
 * @date 2020/12/17 13:54
 */
@RestController
public class EchartsDemoController {
    @Autowired
    private ProductService productService;
    @Autowired
    private PhoneService phoneService;

    @GetMapping("/api/test/product/all")
    public JsonResult getAll(){
        return JsonResult.buildSuccess(200,productService.all());
    }

    @GetMapping("/api/test/phone/all")
    public JsonResult findAll(@RequestHeader("auth-token")String token){
        System.out.println(token);
        return JsonResult.buildSuccess(200,phoneService.allPhones());
    }
}
